package com.zhudeshuai.zhudemolist.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;

import com.zhudeshuai.zhudemolist.R;

public class TabLayoutDemoActivity extends Activity {

    private TabLayout mTabLayout;
    private final String[] tabs = new String[]{"首页", "新闻", "数码科技", "NBA", "娱乐", "科技", "手机", "技术前沿"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab_layout_demo);

        mTabLayout = (TabLayout) findViewById(R.id.tabLayout);
        mTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);

        for (String tab : tabs) {
            TabLayout.Tab tabView = mTabLayout.newTab().setText(tab);
            mTabLayout.addTab(tabView);
        }
        mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });

    }


    public static void open(Activity activity) {
        activity.startActivity(new Intent(activity, TabLayoutDemoActivity.class));
    }
}
